import matplotlib.pyplot as plt import numpy as np from PIL import Image import pandas as pd from collections import OrderedDict %matplotlib qt

In [29]:
cd "K:\Pat's_Projects\Hamamatsu LUT Generation"
K:\Pat's_Projects\Hamamatsu LUT Generation

Open Images

In [30]:
no_lut = Image.open('No_LUT.png')
wl_780 = Image.open('780nm.png')
wl_790 = Image.open('790nm.png')
wl_800 = Image.open('800nm.png')
all_screens = [no_lut,wl_780,wl_790,wl_800]

Crop and get arrays

In [31]:
np.array(no_lut.crop((1280,0,2080,600)).convert('LA').getdata())[:,0]
Out[31]:
array([0, 0, 0, ..., 0, 0, 0])
In [32]:
img_array = []
for img in all_screens:
    cropped = img.crop((1280,0,2080,600))
    img_array.append(np.array(cropped.convert('LA').getdata())[:,0].reshape((cropped.size[1],cropped.size[0])))
In [37]:
img_slice = []
for img in img_array:
    img_slice.append(img[300,:])

Create Lookup Tables

In [74]:
file_names = ['780nm.lut','790nm.lut','800nm.lut']
for num,temp_slice in enumerate(img_slice[1:]):
    
    temp = np.vstack((img_slice[0],temp_slice)).T.astype(np.int)
    sort = np.sort(temp, axis=0)
    # Use Pandas to drop duplicates and make back into array
    sort = pd.DataFrame(sort).drop_duplicates().values
    np.savetxt(file_names[num],sort,fmt='%d')
In [ ]: